<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet" />
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}" />
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}" />
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <script th:src="@{/plugins/layui/layui.js}"></script>
    <title>产能管理</title>
</head>
<body>
<div class="margin clearfix">
    <div class="stystems_style">
        <div class="tabbable">
            <div class="page-content clearfix">
                <div id="Member_Ratings">
                    <div class="tab-content">
                        <div id="home" class="tab-pane active">
                            <!---->
                            <div class="border clearfix">
                                <span class="l_f">
                                <a href="javascript:;" id="member_add" class="btn btn-warning"><i class="icon-plus"></i>添加产线</a>
                                </span>
                            </div>
                            <table id="demo" lay-filter="demo"></table>
                            <script>
                                layui.use('table', function(){
                                    var table = layui.table;
                                    //第一个实例
                                    table.render({
                                        elem: '#demo'
                                        ,url: '/production/sc_cn' //数据接口
                                        ,cols: [
                                            [ //表头
                                            {field: 'id', title: '编号', sort: true, fixed: 'left'}
                                            ,{field: 'productionName', title: '名称'}
                                            ,{field: 'productionCapacity', title: '生产能力',  templet:function(res){
                                                return '<span>'+res.productionCapacity+'组/天</span>';
                                                }
                                            }
                                            ,{field: 'model', title: '生产型号'}
                                            ,{field: 'principal', title: '负责人'}
                                            ,{field: 'number', title: '产线人数', sort: true}
                                            ,{field: 'state', title: '状态',templet:function(res) {
                                                    if (res.state == "1") {
                                                        return '<span style="color: red">正在生产</span>'
                                                    }else {
                                                        return '<span style="color: red">未生产</span>'
                                                    }
                                            }}
                                            ,{field: 'remarks', title: '备注', sort: true}
                                            ,{fixed: 'right',title: '操作', align:'center', toolbar: '#barDemo'}
                                        ]]
                                    });
                                });
                            </script>
                            <script type="text/html" id="barDemo">
                                <a title="编辑" class="btn btn-xs btn-info" lay-event="edit"><i class="icon-edit bigger-120"></i></a>
                                <a title="删除" class="btn btn-xs btn-warning" lay-event="del"><i class="icon-trash  bigger-120"></i></a>
                            </script>
                        </div>
                    </div>
                    <!--编辑产线图层-->
                    <div class="add_menber" id="add_menber_styl" style="display:none">
                        <form action="">
                        <ul class=" page-content">
                            <div class="prompt r_f"></div>
                            <li><label class="label_name" >产线名称：</label><span class="add_name"><input value="${param.productionName}"  name="productionName" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
                            <li><label class="label_name" >生产能力：</label><span class="add_name"><input value="" name="生产能力" type="text"  class="text_add"/>&nbsp;组/天</span><div class="prompt r_f"></div></li>
                            <li style="position: relative;left: -5px;"><label class="label_name" style="width: 85px;">可生产型号：</label><span class="add_name"><input value="" name="可生产型号" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
                            <li><label class="label_name" >负责人：</label><span class="add_name"><input  value="" name="负责人" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
                            <li><label class="label_name">产线人数：</label><span class="add_name"><input value="" name="产线人数" type="text"  class="text_add"/></span><div class="prompt r_f"></div></li>
                            <li><label class="label_name">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：</label><span class="add_name">
     <label><input name="form-field-radio2" type="radio" checked="checked" class="ace"><span class="lbl">正在生产</span></label>&nbsp;&nbsp;&nbsp;
     <label><input name="form-field-radio2"type="radio" class="ace"><span class="lbl">未生产</span></label></span><div class="prompt r_f"></div></li>
                            <li class="adderss"><label class="label_name" style="width:84px">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：</label><span class="add_name"><input value="" name="备注" type="textarea"  class="text_add" style=" width:350px"/></span><div class="prompt r_f"></div></li>
                        </ul>
                        </form>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    layui.use('table', function() {
        var table = layui.table;
        var $ = layui.jquery;
        //监听工具条
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    $.ajax({
                        url : '/production/sc_del',
                        type : 'post',
                        data: {'id':data.id},
                        dataType : 'json',                          //表示服务器返回给我们的数据是json格式
                        success : function (data) {
                            if (data == 1) {
                                layui.table.reload("demo");
                            }
                        }
                    })
                    layer.close(index)
                });
            } else if (obj.event === 'edit') {
                var data =$.param(data);
                layer.open({
                    type: 2,
                    title: '编辑产线',
                    maxmin: true,
                    shadeClose:false, //点击遮罩关闭层
                    area : ['800px' , '400px'],
                    content:'/production/depts?'+data

                });
            }
        });
        $('#member_add').on('click', function(){
            layer.open({
                type: 2,
                title: '添加产线',
                maxmin: true, //开启最大化最小化按钮
                area: ['800px', '400px'],
                content: "/production/dept"
            });
        });
    });
    /*产线-编辑*/
    function member_edit(id){
        layer.open({
            type: 1,
            title: '编辑产线',
            maxmin: true,
            shadeClose:false, //点击遮罩关闭层
            area : ['800px' , ''],
            content:$('#add_menber_styl'),
            btn:['确认修改','取消'],
            yes:function(index,layero){
                var num=0;
                var str="";
                $(".add_menber input[type$='text']").each(function(n){
                    if($(this).val()=="")
                    {

                        layer.alert(str+=""+$(this).attr("name")+"不能为空！\r\n",{
                            title: '提示框',
                            icon:0,
                        });
                        num++;
                        return false;
                    }
                });
                if(num>0){  return false;}
                else{
                    layer.alert('修改成功！',{
                        title: '提示框',
                        icon:1,
                    });
                    layer.close(index);
                }
            }
        });
    }
</script>
